home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / flstory.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  3KB  |  148 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8. #include "driver.h"
  9. #include "vidhrdw/generic.h"
  10.  
  11.  
  12. static int palette_bank;
  13.  
  14.  
  15. void flstory_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  16. {
  17.     int i;
  18.  
  19.  
  20.     /* no color PROMs here, only RAM, but the gfx data is inverted so we */
  21.     /* cannot use the default lookup table */
  22.     for (i = 0;i < Machine->drv->color_table_len;i++)
  23.         colortable[i] = i ^ 0x0f;
  24. }
  25.  
  26.  
  27.  
  28. int flstory_vh_start(void)
  29. {
  30.     paletteram = malloc(0x200);
  31.     paletteram_2 = malloc(0x200);
  32.     return generic_vh_start();
  33. }
  34.  
  35. void flstory_vh_stop(void)
  36. {
  37.     free(paletteram);
  38.     paletteram = 0;
  39.     free(paletteram_2);
  40.     paletteram_2 = 0;
  41.     generic_vh_stop();
  42. }
  43.  
  44.  
  45.  
  46. WRITE_HANDLER( flstory_palette_w )
  47. {
  48.     if (offset & 0x100)
  49.         paletteram_xxxxBBBBGGGGRRRR_split2_w((offset & 0xff) + (palette_bank << 8),data);
  50.     else
  51.         paletteram_xxxxBBBBGGGGRRRR_split1_w((offset & 0xff) + (palette_bank << 8),data);
  52. }
  53.  
  54. WRITE_HANDLER( flstory_gfxctrl_w )
  55. {
  56.     palette_bank = (data & 0x20) >> 5;
  57. //logerror("%04x: gfxctrl = %02x\n",cpu_get_pc(),data);
  58. }
  59.  
  60.  
  61.  
  62. /***************************************************************************
  63.  
  64.   Draw the game screen in the given osd_bitmap.
  65.   Do NOT call osd_update_display() from this function, it will be called by
  66.   the main emulation engine.
  67.  
  68. ***************************************************************************/
  69. void flstory_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  70. {
  71.     int offs;
  72.  
  73.  
  74.     if (palette_recalc())
  75.         memset(dirtybuffer,1,videoram_size);
  76.  
  77.     for (offs = videoram_size - 2;offs >= 0;offs -= 2)
  78.     {
  79.         if (dirtybuffer[offs] || dirtybuffer[offs+1])
  80.         {
  81.             int sx,sy;
  82.  
  83.  
  84.             dirtybuffer[offs] = 0;
  85.             dirtybuffer[offs+1] = 0;
  86.  
  87.             sx = (offs/2)%32;
  88.             sy = (offs/2)/32;
  89.  
  90.             drawgfx(tmpbitmap,Machine->gfx[0],
  91.                     videoram[offs] + ((videoram[offs + 1] & 0xc0) << 2) + 0xc00,
  92.                     videoram[offs + 1] & 0x07,
  93.                     videoram[offs + 1] & 0x08,1,
  94.                     8*sx,8*sy,
  95.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  96.         }
  97.     }
  98.  
  99.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  100.  
  101.     for (offs = 0;offs < spriteram_size;offs += 4)
  102.     {
  103.         int code,sx,sy,flipx,flipy;
  104.  
  105.  
  106.         code = spriteram[offs+2] + ((spriteram[offs+1] & 0x30) << 4);
  107.         sx = spriteram[offs+3];
  108.         sy = 240 - spriteram[offs+0];
  109.         flipx = spriteram[offs+1]&0x40;
  110.         flipy = spriteram[offs+1]&0x80;
  111.  
  112.         drawgfx(bitmap,Machine->gfx[1],
  113.                 code,
  114.                 spriteram[offs+1] & 0x0f,
  115.                 flipx,flipy,
  116.                 sx,sy,
  117.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  118.         /* wrap around */
  119.         if (sx > 240)
  120.             drawgfx(bitmap,Machine->gfx[1],
  121.                     code,
  122.                     spriteram[offs+1] & 0x0f,
  123.                     flipx,flipy,
  124.                     sx-256,sy,
  125.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  126.     }
  127.  
  128.     /* redraw chars with priority over sprites */
  129.     for (offs = videoram_size - 2;offs >= 0;offs -= 2)
  130.     {
  131.         if (videoram[offs + 1] & 0x20)
  132.         {
  133.             int sx,sy;
  134.  
  135.  
  136.             sx = (offs/2)%32;
  137.             sy = (offs/2)/32;
  138.  
  139.             drawgfx(bitmap,Machine->gfx[0],
  140.                     videoram[offs] + ((videoram[offs + 1] & 0xc0) << 2) + 0xc00,
  141.                     videoram[offs + 1] & 0x07,
  142.                     videoram[offs + 1] & 0x08,1,
  143.                     8*sx,8*sy,
  144.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  145.         }
  146.     }
  147. }
  148.